package grape.file.rest.cloudstorage.mvc;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 兼容在微服务和单机运行下时，下载文件路径问题
 * grape-file为微服务的名称
 * Created by yangwei
 * Created at 2020/3/11 17:43
 */
@Slf4j
@RestController
@RequestMapping(CloudStoragePortalOneController.API_REQUEST_MAPPING)
@ApiIgnore
public class CloudStoragePortalOneController extends CloudStorageController {
    public static final String API_REQUEST_MAPPING = "/grape-file/file/cloudstorage";
    public static final String API_DOWNLOAD = "/download";
    public static final String API_DOWNLOAD_PREFIX = API_REQUEST_MAPPING + API_DOWNLOAD;

    @GetMapping( API_DOWNLOAD + "/**")
    @Override
    public void download(HttpServletRequest request, HttpServletResponse response, String uploadType) throws Throwable {
        super.download(request, response, uploadType);
    }
    /**
     * 删除
     * @param request
     */
    @DeleteMapping( API_DOWNLOAD + "/**")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    @Override
    public void delete(HttpServletRequest request, HttpServletResponse response, String uploadType) {
        super.delete(request, response, uploadType);
    }

    @Override
    public String getPrefix() {
        return API_DOWNLOAD_PREFIX;
    }
}
